//
//  HYBaseNavigationController.m
//  HYChatProject
//
//  Created by erpapa on 16/3/20.
//  Copyright © 2016年 erpapa. All rights reserved.
//

#import "HYNavigationController.h"

@interface HYNavigationController ()

@end

@implementation HYNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initNavView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)initNavView
{
    self.navigationBar.barTintColor = APP_MAIN_COLOR;
    if ([UIDevice currentDevice].systemVersion.doubleValue <= 6) {
        [[UINavigationBar appearance] setBackgroundImage:[self barBackgroundImage] forBarMetrics:UIBarMetricsDefault];
    }
    self.navigationBar.tintColor = [UIColor whiteColor];
    NSMutableDictionary * dict=[NSMutableDictionary dictionaryWithObjects:@[[UIColor whiteColor],[UIFont systemFontOfSize:19]]forKeys:@[NSForegroundColorAttributeName,NSFontAttributeName]];
    [[UINavigationBar appearance] setTitleTextAttributes:dict];
    [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"icon_left"]];
    [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"icon_left"]];
    
}

-(UIImage*)barBackgroundImage{
    
    static UIImage *defaultImage = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        UIGraphicsBeginImageContextWithOptions(CGSizeMake(20, 44), NO, 0.0f);
        [APP_MAIN_COLOR setFill];
        [[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 20, 44)] fill];
        defaultImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    });
    return defaultImage;
}

@end
